//
//  KQMessageOptions.swift
//  JChat
//
//  Created by JIGUANG on 2017/3/8.
//  Copyright © 2017年 HXHG. All rights reserved.
//

import UIKit
import KQChatSDK

/// 消息类型
@objc public enum KQMessageStyle: Int {
    case notice
    case bubble
    case custom
}

/// 消息对齐方式
@objc public enum KQMessageAlignment: Int {
    case left
    case right
    case center
}

@objc public enum KQMessageState: Int {
    case sending
    case sendError
    case sendSucceed
    case downloadFailed
}

/// 消息选项
@objc open class KQMessageOptions: NSObject {
    
    public override init() {
        super.init()
    }
    
    public convenience init(with content: KQMessageContentType) {
        self.init()
        
        switch content {
        case is KQMessageNoticeContent:
            self.style = .notice
            self.alignment = .center
            self.showsCard = false
            self.showsAvatar = false
            self.showsBubble = true
            self.isUserInteractionEnabled = false
            
        case is KQMessageTimeLineContent:
            self.style = .notice
            self.alignment = .center
            self.showsCard = false
            self.showsAvatar = false
            self.showsBubble = false
            self.isUserInteractionEnabled = false
            
        case is KQMessageRecallContent:
            self.style = .notice
            self.alignment = .center
            self.showsCard = false
            self.showsAvatar = false
            self.showsBubble = false
            self.isUserInteractionEnabled = false
            
        case is KQMessageImageContent:
            self.style = .custom
            self.showsCard = false
            self.showsAvatar = true
            self.showsBubble = false
            self.isUserInteractionEnabled = true
            
        case is KQMessageVideoContent:
            self.style = .custom
            self.showsCard = false
            self.showsAvatar = true
            self.showsBubble = false
            self.isUserInteractionEnabled = true
            
        case is KQMessageQuestionContent:
            self.style = .custom
            self.showsCard = false
            self.showsAvatar = true
            self.showsBubble = true
            self.isUserInteractionEnabled = true

        case is KQMessageAnswerContent:
            self.style = .custom
            self.showsCard = false
            self.showsAvatar = true
            self.showsBubble = true
            self.isUserInteractionEnabled = true

        case is KQMessageHouseKeeperContent:
            self.style = .custom
            self.showsCard = false
            self.showsAvatar = true
            self.showsBubble = true
            self.isUserInteractionEnabled = true
            
        case is KQMessageCustomTipsContent:
            self.style = .notice
            self.alignment = .center
            self.showsCard = false
            self.showsAvatar = false
            self.showsBubble = true
            self.isUserInteractionEnabled = true
            
//        case is KQMessageImageContent:
//            self.showsTips = false
            
        default:
            break
        }
    }
    
    open var style: KQMessageStyle = .bubble
    open var alignment: KQMessageAlignment = .left
    
    open var isUserInteractionEnabled: Bool = true
    
    open var showsCard: Bool = false        //姓名
    open var showsAvatar: Bool =  true      //头像
    open var showsBubble: Bool = true       //气泡
    open var showsTips: Bool = true         //消息状态
    open var state: KQMessageState = .sendSucceed
    
    internal func fix(with content: KQMessageContentType)  {
    }
}

